package com.tjetc;

import org.junit.jupiter.api.Test;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

public class _2Properties {
   /*
    1.使⽤Properties类完成对jdbc.properties的读取。 这个用的很多！！！
    2.使⽤Properties类添加key-val到新⽂件.properties中 几乎不用

    */

    @Test
    public void testProperties1() throws IOException {
        Properties properties = new Properties();
        // 这里只要一加载 那么properties对象中就有值了
        properties.load(new FileReader("/Users/gaoyongxiang/百度网盘/IDEA-Java/202507-java-se/chapter16/resource/jdbc.properties"));

        String username = properties.getProperty("username");
        System.out.println("username = " + username);
        String password = properties.getProperty("password");
        System.out.println("password = " + password);
    }

}
